package com.lu.pojo.lambda;

/**
 * @author luzhenfang
 * @date 2020 05 26
 * @description lambda 的应用
 */
public class Calculator {
    interface IntegerMath{
        int operation(int a,int b);
    }
    public int operateBinary(int a,int b, IntegerMath op){
        return op.operation(a,b);
    }
    public static void main(String[] args) {

        Calculator calculator = new Calculator();
        IntegerMath addition = (a,b)->a+b;
        IntegerMath subtraction = (a,b)->a-b;

        System.out.println(calculator.operateBinary(10,20,addition));
        System.out.println(calculator.operateBinary(10,20,subtraction));
        System.out.println(calculator.operateBinary(10,30,(a,b)-> a*b));
        Runnable t1 =()->{
            System.out.println("你好,Lambda！");
        };
        new Thread(t1).start();
    }
}
